/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frm.billingAndPaymentProcessing.session;

import frm.billingAndPaymentProcessing.entity.DunningEmailEntity;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author xhx
 */
@Stateless
@LocalBean
public class DunningEmailSessionBean {

    @PersistenceContext
    private EntityManager em;
    
        public void createDunningEmail(DunningEmailEntity dunningEmail) {
        em.persist(dunningEmail);
    }

    public DunningEmailEntity getDunningEmailById(Long dunningEmailId) {
        return em.find(DunningEmailEntity.class, dunningEmailId);
    }

    public List<DunningEmailEntity> getAllDunningEmail() {
        Query query = em.createQuery("SELECT u FROM DunningEmailEntity");
        return query.getResultList();
    }
  
    public void saveChanges(DunningEmailEntity dunningEmail) {
        em.merge(dunningEmail);
    }
    public void removeDunningEmail(DunningEmailEntity dunningEmail){
        
        em.remove(dunningEmail);
        
}
}
